<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>薪资想过万，代码敲三遍</title>
</head>

<body>
    <script>
        const arr1 = [
            { month: '1月', salary: 17300 },
            { month: '2月', salary: 14300 },
            { month: '3月', salary: 16400 },
            { month: '4月', salary: 17400 },
            { month: '5月', salary: 13300 },
            { month: '6月', salary: 12800 },
            { month: '7月', salary: 21300 },
            { month: '8月', salary: 23600 },
            { month: '9月', salary: 10500 },
            { month: '10月', salary: 19400 },
            { month: '11月', salary: 12100 },
            { month: '12月', salary: 21200 },
        ]
        // 需求1：构建一个新数组，['1月', '2月', '3月', '4月','5月','6月','7月','8月','9月','10月','11月','12月']
        const new1 = arr1.map(item => {
            return item.month
        })
        console.log(new1)

        const arr2 = [
            { label: '1万以下', g_count: 2, b_count: 3 },
            { label: '1-1.5万', g_count: 12, b_count: 15 },
            { label: '1.5-2万', g_count: 20, b_count: 11 },
            { label: '2万以上', g_count: 8, b_count: 9 },
        ]
        // 需求2：构建一个新数组，[{name:'1万以下',value:5},{name:'1-1.5万',value:27},{name:'1.5-2万',value:31},{name:'2万以上',value:17}]
      let new2 =  arr2.map(function(e){
        // console.log(e);
         return {
           name:e.label,
           value:e.g_count + e.b_count
         }
       })
       console.log(new2);
          

        const arr3 = [
            { name: '万涛', hope_salary: 12600, salary: 16000 },
            { name: '戴军', hope_salary: 12000, salary: 12200 },
            { name: '方娟', hope_salary: 13300, salary: 18200 },
            { name: '程丽', hope_salary: 13000, salary: 16200 },
            { name: '贾磊', hope_salary: 14400, salary: 11100 },
            { name: '阎娜', hope_salary: 10600, salary: 16100 },
            { name: '吴强', hope_salary: 13400, salary: 10800 },
            { name: '田芳', hope_salary: 10100, salary: 11300 },
            { name: '段桂英', hope_salary: 12500, salary: 23800 },
            { name: '邹芳', hope_salary: 14100, salary: 19900 },
        ]
        // 需求3：构建一个新数组，['万涛',戴军','方娟','程丽',......]
  
         let new3 =  arr3.map(function(e){
             return e.name
          })
          console.log(new3);
              


        const dataList = [
            { name: '南海诸岛', value: 0 },
            { name: '北京', value: 0 },
            { name: '天津', value: 0 },
            { name: '上海', value: 0 },
            { name: '重庆', value: 0 },
            { name: '河北', value: 0 },
            { name: '河南', value: 0 },
            { name: '云南', value: 0 },
            { name: '辽宁', value: 0 },
            { name: '黑龙江', value: 0 },
            { name: '湖南', value: 0 },
            { name: '安徽', value: 0 },
            { name: '山东', value: 0 },
            { name: '新疆', value: 0 },
            { name: '江苏', value: 0 },
            { name: '浙江', value: 0 },
            { name: '江西', value: 0 },
            { name: '湖北', value: 0 },
            { name: '广西', value: 0 },
            { name: '甘肃', value: 0 },
            { name: '山西', value: 0 },
            { name: '内蒙古', value: 0 },
            { name: '陕西', value: 0 },
            { name: '吉林', value: 0 },
            { name: '福建', value: 0 },
            { name: '贵州', value: 0 },
            { name: '广东', value: 0 },
            { name: '青海', value: 0 },
            { name: '西藏', value: 0 },
            { name: '四川', value: 0 },
            { name: '宁夏', value: 0 },
            { name: '海南', value: 0 },
            { name: '台湾', value: 0 },
            { name: '香港', value: 0 },
            { name: '澳门', value: 0 },
        ]
        const arr4 = [
            { name: '湖南省', value: 3 },
            { name: '吉林省', value: 3 },
            { name: '山西省', value: 1 },
            { name: '陕西省', value: 5 },
            { name: '北京', value: 9 },
            { name: '安徽省', value: 3 },
            { name: '云南省', value: 6 },
            { name: '广西壮族自治区', value: 2 },
            { name: '贵州省', value: 1 },
            { name: '宁夏回族自治区', value: 4 },
            { name: '河南省', value: 5 },
            { name: '江苏省', value: 2 },
            { name: '福建省', value: 4 },
            { name: '上海', value: 2 },
            { name: '河北省', value: 1 },
            { name: '黑龙江省', value: 3 },
            { name: '山东省', value: 3 },
            { name: '西藏自治区', value: 5 },
            { name: '湖北省', value: 2 },
            { name: '内蒙古自治区', value: 1 },
            { name: '广东省', value: 1 },
            { name: '江西省', value: 2 },
            { name: '天津', value: 2 },
            { name: '辽宁省', value: 2 },
            { name: '青海省', value: 1 },
            { name: '四川省', value: 1 },
            { name: '新疆维吾尔自治区', value: 3 },
            { name: '重庆', value: 1 },
            { name: '浙江省', value: 1 },
            { name: '甘肃省', value: 1 },
        ]
        // 需求4：把arr4中元素的value值赋值给dataList数组中的元素（省份对应）
        
       let a1 = arr4.map(function(ele){
           return {
           name : ele.name.substring(0,[2]),
           value:ele.value
           }
            })
           
            dataList.forEach(function(item){
               const ic = item.name
               const obj =  a1.find(function(it){
                    return it.name.includes(ic)
                })
                if(obj){
                    item.value = obj.value
                }
            })
    
             console.log(dataList);



    </script>
</body>

</html>